/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package ER.impl;

import ER.ERPackage;
import ER.Entity;
import ER.Relation;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Relation</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ER.impl.RelationImpl#getDestiny <em>Destiny</em>}</li>
 *   <li>{@link ER.impl.RelationImpl#getOrigin <em>Origin</em>}</li>
 *   <li>{@link ER.impl.RelationImpl#getCOrigin <em>COrigin</em>}</li>
 *   <li>{@link ER.impl.RelationImpl#getCDestiny <em>CDestiny</em>}</li>
 *   <li>{@link ER.impl.RelationImpl#getName <em>Name</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class RelationImpl extends EObjectImpl implements Relation {
	/**
	 * The cached value of the '{@link #getDestiny() <em>Destiny</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDestiny()
	 * @generated
	 * @ordered
	 */
	protected Entity destiny;

	/**
	 * The cached value of the '{@link #getOrigin() <em>Origin</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOrigin()
	 * @generated
	 * @ordered
	 */
	protected Entity origin;

	/**
	 * The default value of the '{@link #getCOrigin() <em>COrigin</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCOrigin()
	 * @generated
	 * @ordered
	 */
	protected static final String CORIGIN_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getCOrigin() <em>COrigin</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCOrigin()
	 * @generated
	 * @ordered
	 */
	protected String cOrigin = CORIGIN_EDEFAULT;

	/**
	 * The default value of the '{@link #getCDestiny() <em>CDestiny</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCDestiny()
	 * @generated
	 * @ordered
	 */
	protected static final String CDESTINY_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getCDestiny() <em>CDestiny</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCDestiny()
	 * @generated
	 * @ordered
	 */
	protected String cDestiny = CDESTINY_EDEFAULT;

	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RelationImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ERPackage.Literals.RELATION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Entity getDestiny() {
		if (destiny != null && destiny.eIsProxy()) {
			InternalEObject oldDestiny = (InternalEObject)destiny;
			destiny = (Entity)eResolveProxy(oldDestiny);
			if (destiny != oldDestiny) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ERPackage.RELATION__DESTINY, oldDestiny, destiny));
			}
		}
		return destiny;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Entity basicGetDestiny() {
		return destiny;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDestiny(Entity newDestiny) {
		Entity oldDestiny = destiny;
		destiny = newDestiny;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ERPackage.RELATION__DESTINY, oldDestiny, destiny));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Entity getOrigin() {
		if (origin != null && origin.eIsProxy()) {
			InternalEObject oldOrigin = (InternalEObject)origin;
			origin = (Entity)eResolveProxy(oldOrigin);
			if (origin != oldOrigin) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ERPackage.RELATION__ORIGIN, oldOrigin, origin));
			}
		}
		return origin;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Entity basicGetOrigin() {
		return origin;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOrigin(Entity newOrigin) {
		Entity oldOrigin = origin;
		origin = newOrigin;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ERPackage.RELATION__ORIGIN, oldOrigin, origin));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getCOrigin() {
		return cOrigin;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCOrigin(String newCOrigin) {
		String oldCOrigin = cOrigin;
		cOrigin = newCOrigin;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ERPackage.RELATION__CORIGIN, oldCOrigin, cOrigin));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getCDestiny() {
		return cDestiny;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCDestiny(String newCDestiny) {
		String oldCDestiny = cDestiny;
		cDestiny = newCDestiny;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ERPackage.RELATION__CDESTINY, oldCDestiny, cDestiny));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ERPackage.RELATION__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ERPackage.RELATION__DESTINY:
				if (resolve) return getDestiny();
				return basicGetDestiny();
			case ERPackage.RELATION__ORIGIN:
				if (resolve) return getOrigin();
				return basicGetOrigin();
			case ERPackage.RELATION__CORIGIN:
				return getCOrigin();
			case ERPackage.RELATION__CDESTINY:
				return getCDestiny();
			case ERPackage.RELATION__NAME:
				return getName();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ERPackage.RELATION__DESTINY:
				setDestiny((Entity)newValue);
				return;
			case ERPackage.RELATION__ORIGIN:
				setOrigin((Entity)newValue);
				return;
			case ERPackage.RELATION__CORIGIN:
				setCOrigin((String)newValue);
				return;
			case ERPackage.RELATION__CDESTINY:
				setCDestiny((String)newValue);
				return;
			case ERPackage.RELATION__NAME:
				setName((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ERPackage.RELATION__DESTINY:
				setDestiny((Entity)null);
				return;
			case ERPackage.RELATION__ORIGIN:
				setOrigin((Entity)null);
				return;
			case ERPackage.RELATION__CORIGIN:
				setCOrigin(CORIGIN_EDEFAULT);
				return;
			case ERPackage.RELATION__CDESTINY:
				setCDestiny(CDESTINY_EDEFAULT);
				return;
			case ERPackage.RELATION__NAME:
				setName(NAME_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ERPackage.RELATION__DESTINY:
				return destiny != null;
			case ERPackage.RELATION__ORIGIN:
				return origin != null;
			case ERPackage.RELATION__CORIGIN:
				return CORIGIN_EDEFAULT == null ? cOrigin != null : !CORIGIN_EDEFAULT.equals(cOrigin);
			case ERPackage.RELATION__CDESTINY:
				return CDESTINY_EDEFAULT == null ? cDestiny != null : !CDESTINY_EDEFAULT.equals(cDestiny);
			case ERPackage.RELATION__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (cOrigin: ");
		result.append(cOrigin);
		result.append(", cDestiny: ");
		result.append(cDestiny);
		result.append(", Name: ");
		result.append(name);
		result.append(')');
		return result.toString();
	}

} //RelationImpl
